package apis

import (
	"cloud.google.com/go/language/apiv2/languagepb"
	"context"
)

func (s *ApiClient) ExtractEntities(ctx context.Context, content string) ([]*languagepb.Entity, error) {
	resp, err := s.cli.AnalyzeEntities(ctx, &languagepb.AnalyzeEntitiesRequest{
		Document: &languagepb.Document{
			Source: &languagepb.Document_Content{
				Content: content,
			},
			Type: languagepb.Document_PLAIN_TEXT,
		},
		EncodingType: languagepb.EncodingType_UTF8,
	})

	if err != nil {
		return nil, err
	}
	return resp.Entities, nil
}
